package fantasyday.wowzolo.web.common;

import fantasyday.wowzolo.web.account.SignonPage;
import org.apache.wicket.Component;
import org.apache.wicket.RestartResponseAtInterceptPageException;
import org.apache.wicket.authorization.IUnauthorizedComponentInstantiationListener;
import org.apache.wicket.authorization.strategies.page.AbstractPageAuthorizationStrategy;

public final class AuthorizationStrategy extends AbstractPageAuthorizationStrategy implements IUnauthorizedComponentInstantiationListener {

    protected boolean isPageAuthorized(final Class pageClass) {
        return !pageClass.isAnnotationPresent(SecurePage.class) || WowzoloSession.getJpetstoreSession().isSignon();
    }

    public void onUnauthorizedInstantiation(Component component) {
        throw new RestartResponseAtInterceptPageException(SignonPage.class);
    }
}
